<?
require_once('./lib/Config.php');
require_once('./lib/DB.gear.php');
require_once('./lib/Template.gear.php');
require_once('./lib/lib.gear.php');
require_once('./lib/lib.garden.php');
require_once('./lib/signup.class.php');

$user_id = $_GET['user_id'];
$id_type = $_GET['id_type'];

	$url = 'http://reafo.net/garden/api/user.php';
	$data = array(
	    'user_id'              => $user_id,
	    'id_type'              => $id_type,
		'type'               => 'is_user',
	    'g_key_din39s03j23ogn' => G_KEY,
	);

	$headers = array(
	    'Authorization: OAuth '.'todoke', 
	);

	$options = array('http' => array(
	    'method' => 'POST',
	    'content' => http_build_query($data),
	    'header' => implode("\r\n", $headers),
	));

	$contents = file_get_contents($url, false, stream_context_create($options));


    $comments = json_decode($contents, true);
    preDump($comments);

$invitee_id = "asir3h94fa3:a3p98da3fnp3:a3udp39fhp38:3p8a3jda3pa:";

$invitees = explode(":", substr($invitee_id, 0, -1));

preDump($invitees);

$signup = new SIGNUP;

foreach($invitees as $invitee_id)
{
	if($signup->load_user($invitee_id, 'mixi'))
	{
		//add
		echo 'add : '.$invitee_id;
		preDump($signup->get_user_id());
		
	}
	else
	{
		//invite
		echo 'invite'.$invitee_id.'<br>';
	}

}

/*
$user_id       = $_GET['user_id'];

	$url = 'http://reafo.net/garden/api/feed.php';
	$data = array(
	    'user_id'              => $user_id,
	    'g_key_din39s03j23ogn' => G_KEY,
	);

	if(isset($_GET['count']) && ($_GET['count'] > 0))
	{
		$data['count'] = $_GET['count'];
		
	}

	if(isset($_GET['startIndex']))
	{
	    $data['startIndex'] = $_GET['startIndex'];
	}

	$headers = array(
	    'Authorization: OAuth '.'todoke', 
	);

	$options = array('http' => array(
	    'method' => 'POST',
	    'content' => http_build_query($data),
	    'header' => implode("\r\n", $headers),
	));

	$contents = file_get_contents($url, false, stream_context_create($options));


    $comments = json_decode($contents, true);
    preDump($comments);
*/


?>
